#ifndef __ILIB_TIMER_H_20120415__
#define __ILIB_TIMER_H_20120415__

#include "../../iHeader.h"

class iMsgThread;
class iTimer
{
public:
	class iSink
	{
	public:
		virtual void on_timer(iTimer* tmr) = 0;
	};

	static iTimer* new_instance(iSink* sink, uint32_t id, uint32_t interval, uint32_t loop=1);
	void release();
	
	inline bool is_release() { return m_released; }
	inline bool is_stopped() { return m_stopped;  }
	inline iSink* get_sink() { return m_sink; }
	inline uint32_t get_id() { return m_param.id; }
	inline iMsgThread* get_launcher() { return m_launcher; }
	inline uint32_t get_interval() { return m_param.interval; }
	inline uint32_t get_loop() { return m_param.loop; }
private:
	friend class iTimerWheel;
	iTimer::iSink*	m_sink;
	iMsgThread* m_launcher;
	struct Parameter {
		uint32_t id;uint32_t interval;uint32_t loop;void* user_data;
	}			m_param;
	bool		m_released;
	bool		m_stopped;
};
#endif  //__ILIB_TIMER_H_20120415__